package strcy.cn.market.mapper;

import org.apache.ibatis.annotations.*;
import strcy.cn.market.pojo.Product;
import strcy.cn.market.pojo.VO.ProductVO;

import java.util.List;

@Mapper
public interface ProductMapper {
    //新增商品
    @Insert("insert into products(product_name,img, status,description, price, stock_quantity, created_at, category_id) " +
            "value (#{productName},#{img},#{status},#{description},#{price},#{stockQuantity},NOW(),#{categoryId})")
    void add(Product product);
    //根据商品ID删除商品
    @Delete("delete from products where product_id=#{id}")
    void deleteById(Integer id);
    //更新商品信息
    @Update("update products set img=#{img},status=#{status}, product_name=#{productName},description=#{description},price=#{price},stock_quantity=#{stockQuantity} where product_id=#{productId}")
    void update(Product product);
    //获取商品列表

    List<ProductVO> list();
    //更新商品上下架状态
    @Update("update products set status=#{status} where product_id=#{id}")
    void updateStatus(String status, Integer id);
    //根据商品ID获取商品详情
    ProductVO getById(Integer productId);
}
